package com.example.app6;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class UCActivity1 extends AppCompatActivity {

    private LinearLayout buttonContainer;
    private Button btnHorizontal;
    private Button btnVertical;
    private Button btnAlignLeft;
    private Button btnBack;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ucacitvity1);


        buttonContainer = findViewById(R.id.buttonContainer);
        btnHorizontal = findViewById(R.id.btn21_horizontal);
        btnVertical = findViewById(R.id.btn22_vertical);
        btnAlignLeft = findViewById(R.id.btn23_align_left);
        btnBack = findViewById(R.id.btn_back_main);


        // "水平布局" (Horizontal Layout) button
        btnHorizontal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                buttonContainer.setOrientation(LinearLayout.HORIZONTAL);
                buttonContainer.setGravity(Gravity.CENTER);
            }
        });

        // "垂直布局" (Vertical Layout) button
        btnVertical.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                buttonContainer.setOrientation(LinearLayout.VERTICAL);
                buttonContainer.setGravity(Gravity.CENTER_HORIZONTAL);
            }
        });

        // "靠左对齐" (Align Left) button
        btnAlignLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                buttonContainer.setOrientation(LinearLayout.VERTICAL);
                buttonContainer.setGravity(Gravity.START); // For LTR languages, this is left
            }
        });

        btnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}